Skip to content

C++: Disable cpp/implicit-function-declaration on build mode none databases#21553

Open
geoffw0 wants to merge 6 commits intogithub:mainfrom
geoffw0:implicitfn
Open

C++: Disable cpp/implicit-function-declaration on build mode none databases#21553
geoffw0 wants to merge 6 commits intogithub:mainfrom
geoffw0:implicitfn

Conversation

@geoffw0
Copy link
Copy Markdown
Contributor

@geoffw0 geoffw0 commented Mar 23, 2026

Disable results from cpp/implicit-function-declaration on build mode: none (buildless) databases. This query is very noisy with false positive results on many of these databases, and I believe the cause is fundamental to what BMN is (i.e. not fixable for BMN).

@geoffw0 geoffw0 requested a review from a team as a code owner March 23, 2026 14:59
Copilot AI review requested due to automatic review settings March 23, 2026 14:59
@geoffw0 geoffw0 added the C++ label Mar 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Disables cpp/implicit-function-declaration findings on build mode: none (buildless) databases to avoid fundamentally imprecise / noisy results.

Changes:

  • Added a build-mode guard to suppress results for cpp/implicit-function-declaration on build mode: none databases.
  • Added a change note documenting the analysis behavior change.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
cpp/ql/src/change-notes/2026-03-23-implicit-function-declaration.md Documents that the query is now suppressed on build mode: none databases.
cpp/ql/src/Likely Bugs/Underspecified Functions/ImplicitFunctionDeclaration.ql Adds a build-mode check intended to prevent results on build mode: none databases.

@jketema
Copy link
Copy Markdown
Contributor

jketema commented Mar 23, 2026

I think we need some internal discussion on this. We're now flip-flopping between lowing the accuracy and explicitly disabling the query in BMN (which we did before we lowered the accuracy).

@github-actions
Copy link
Copy Markdown
Contributor

QHelp previews:

cpp/ql/src/Likely Bugs/Underspecified Functions/ImplicitFunctionDeclaration.qhelp

Implicit function declaration

A function is called without a prior function declaration or definition. When this happens, the compiler generates an implicit declaration of the function, specifying an integer return type and no parameters. If the implicit declaration does not match the true signature of the function, the function may behave unpredictably.

This may indicate a misspelled function name, or that the required header containing the function declaration has not been included.

Note: This query is not compatible with build mode: none databases, and produces no results on those databases.

Recommendation

Provide an explicit declaration of the function before invoking it.

Example

/* '#include <stdlib.h>' was forgotten */

int main(void) {
	/* 'int malloc()' assumed */
	unsigned char *p = malloc(100);
	*p = 'a';
	return 0;
}

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants